package com.chenshuang.dao;

import com.chenshuang.bean.Admin;

public class AdminDao extends BasicDao<Admin> {

    public Admin getAP(String username, String password) {
        return querySingle("select * from admin where username=? and password=?", Admin.class, username, password);
    }

    public int insert(Admin admin) {
        Admin query = querySingle("select username from admin where username = ?", Admin.class, admin.getUsername());

        if (query==null){
            return update("insert into admin(username,password,sex) values(?,?,?)",
                    admin.getUsername(), admin.getPassword(), admin.getSex());
        }else {
            return 2;
        }
    }
}
